<!--
 * @Author: ChunLai
 * @Date: 2023-07-25 09:48:14
 * @LastEditTime: 2025-07-24 14:50:02
 * @Description: 银行卡限额表弹出框
 * @FilePath: \02.bldinsure\src\components\BankLimitTable.vue
-->
<template>
  <!-- :style="{ height: '80%' }" -->
  <van-popup
    v-model="showPop"
    round
    position="bottom"
    closeable
    @click-close-icon="showPop = false"
    @click-overlay="showPop = false"
  >
    <div class="top">
      <div class="title">银行卡可用列表</div>
      <div class="tip">只支持借记卡，不支持信用卡和存折</div>
    </div>
    <div class="main flex-col">
      <div class="tab-list">
        <span
          v-for="tab in payModeList"
          :key="tab.value"
          :class="[{ active: activeIndex === tab.value }]"
          @click="activeIndex = tab.value"
        >
          {{ tab.label }}
        </span>
      </div>
      <div class="cont">
        <div class="bank-unit">
          <span class="sw_40">银行名称</span>
          <span class="sw_100">单笔限额</span>
          <span class="sw_100">单日限额</span>
        </div>
        <div class="bank-unit-box">
          <template v-for="(item, idx) in bankList">
            <div
              class="bank-unit"
              :key="`bank_${idx}_info`"
              v-if="showList(item)"
            >
              <span class="sw_40 txt-left">
                <em class="icon-bank">
                  <img :src="item.img" alt="" v-if="item.img" />
                </em>
                <i class="bank-name ft12">{{ item.text }}</i>
              </span>
              <template v-if="activeIndex === 'R'">
                <span class="sw_100">{{ item.small }}</span>
                <span class="sw_100">{{ item.big }}</span>
              </template>
              <template v-if="activeIndex === '7'">
                <span class="sw_100">{{ item.batch }}</span>
                <span class="sw_100">{{ item.batch2 || item.batch }}</span>
              </template>
            </div>
          </template>
        </div>
      </div>
    </div>
  </van-popup>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  name: "BankLimitTable",
  data() {
    return {
      activeIndex: "R",
      scrollHeight: 300, //实时屏幕高度
      showPop: false,
    };
  },
  computed: {
    ...mapGetters({
      bankList: "dictionary/bankList",
      payModeList: "dictionary/payModeList",
    }),
  },
  mounted() {
    this.$nextTick(() => {
      const winH = document.documentElement.clientHeight;
      this.scrollHeight = winH * 0.8 - 150;
    });
  },
  methods: {
    initCompnt() {
      this.showPop = true;
    },
    showList(item) {
      if (this.activeIndex == "R") return item.bankR;
      if (this.activeIndex == "7") return item.bank7;
      return true;
    },
  },
};
</script>

<style lang="less" scoped>
.sw_40 {
  width: calc(100% - 200px);
}
.sw_100 {
  width: 100px;
  text-align: center;
}

.top {
  position: relative;
  text-align: center;
  width: 100%;
  padding: 10px;

  .title {
    font-size: 16px;
  }

  .tip {
    color: #fdab82;
    font-size: 13px;
  }

  .icon-off {
    position: absolute;
    font-size: 20px;

    right: 5px;
    top: 5px;
  }
}

.main {
  width: 100%;
  height: 75vh;
  overflow-y: auto;
  .tab-list {
    display: flex;
    width: 100%;
    height: 40px;
    background: #f0f0f0;
    span {
      display: flex;
      align-items: center;
      justify-content: center;
      flex: 1;
      &.active {
        color: #ffffff;
        background: #e60012;
      }
    }
  }

  .cont {
    flex: 1;
    overflow: auto;
    width: 100%;
  }
}

.bank-unit-box {
  width: 100%;
  height: calc(75vh - 80px);
  overflow: hidden;
  overflow-y: scroll;
}

.bank-unit {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 30px;
  border-bottom: 1px solid #e0f3ff;
  background: #fafdff;
  padding: 4px 0;

  span {
    display: flex;
    justify-content: center;
    align-items: center;

    &.txt-left {
      justify-content: flex-start;
      padding-left: 10px;
    }

    .bank-name {
      line-height: 1.3;
      font-style: normal;
    }

    .icon-bank {
      width: 20px;
      height: 20px;
      margin-right: 6px;
    }
  }
}
</style>
